home *** CD-ROM | disk | FTP | other *** search
- Path: newsbf02.news.aol.com!not-for-mail
- From: razine@aol.com (Razine)
- Newsgroups: comp.lang.c
- Subject: Passing Structures As Pointers; Easy Question I think....
- Date: 3 Mar 1996 13:38:27 -0500
- Organization: America Online, Inc. (1-800-827-6364)
- Sender: root@newsbf02.news.aol.com
- Message-ID: <4hcov3$h1d@newsbf02.news.aol.com>
- Reply-To: razine@aol.com (Razine)
- NNTP-Posting-Host: newsbf02.mail.aol.com
-
- I recently ran into a problem passing a structure as a pointer to a
- function. I then wanted to pass a indivdual variable to another function
- but it didnt work. Here is a brief example. Can anyone spot anything
- wrong.
-
- typedef struct {
- char name[81];
- int address_num;
- } person_rec;
-
-
-
- void main(void) {
- person_rec thisuser;
-
- display_person(&thisuser);
-
- }
-
- void display_address(int address) {
- printf("Adress Number is %d\r\n",address);
- return;
- }
-
- void display_person(person_rec *pr) {
-
- printf("Persons Name : %s\r\n",pr->name); /* another question why in
- this instance would I have to use the -> operand? */
- display_address(pr->address_num);
-
- /* Basically I get an error on the line above, how would I just pass the
- interger value contained in pr->address_num */
-
- return;
- }
-
-
- I hope someone can help, I found a work around but it is sloppy and I want
- to understand why, and what I am doing wrong. Thanks
-
- Darrell
-
-